# Import WS2812 class from the ws2012 library/module, (by this instruction we are saying to import WS2812 function from ws2812 library), this fucntion is used to control WS2812 RGB LEDs (WS2812 is a Neopixel LED)
from ws2812 import WS2812

# Import utime module (by "import utime" we are saying that bring me the whole time toolbox, I’ll grab tools from inside when needed), this module is use for time related fucntions like delay function.
import utime
        
# Import machine module, which gives access to hardware features like GPIO pins.
import machine
        
# Configures GPIO pin 11 as an output pin and assigns it to the variable power.
power = machine.Pin(11,machine.Pin.OUT)
        
# Sets pin 11 to HIGH (1), which likely provides power to the onboard RGB LED circuit.
power.value(1)

# Each tuple represents (RED value, GREEN value, BLUE value) Red, Green, and Blue (RGB) are considered primary colors of light, additive color theory is use to derive different colors.
BLACK = (0, 0, 0)
RED = (255, 0, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
WHITE = (255, 255, 255)

# Creates a tuple named COLORS that stores all above defined colors. This makes it easy to loop through them later.
COLORS = (BLACK, RED, YELLOW, GREEN, CYAN, BLUE, PURPLE, WHITE)

# WS2812(pin_num,led_count), Creates an object named led and Control 1 WS2812 LED connected to GPIO 12.
led = WS2812(12,1)

# Start an infinite loop everything inside this loop will repeat forever.
while True:
    # Prints this message to the Thonny serial console each time the loop runs.
    print("Beautiful color")
    # Loops through each color stored in the COLORS tuple, one by one.
    for color in COLORS:
        # Sets the LED to the current color in the loop.
        led.pixels_fill(color)
        # Sends the color data to the LED so it actually updates and lights up. Without this line, the color wouldn’t change visually.
        led.pixels_show()
        # Waits for 0.2 seconds
        utime.sleep(0.2)